﻿using System;

namespace EmbeddedSharp.Core.Function.DateTime {

    /// <summary>
    /// echo(date());
    /// </summary>
    public class DateNode : FuncNode {

        public DateNode() {
            Value = "date";
        }

        public override object Evaluate() {
            if (Parameters.Count < 0)
            {
                return System.DateTime.Today.Date.ToString();
            }

            string format = Convert.ToString(
                Parameters[0].Evaluate());
            return System.DateTime.Now.ToString(format);
        }
    }
}
